package com.simpleframe.views.chart.attribution;

/**
 * 数据对象
 * @author Administrator
 *
 */
public class ChartElements {

	/**
	 * 柱状图  pie 
	 */
	public static final String TYPE_BAR = "bar";
	
	/**
	 * 水晶柱状图
	 */
	public static final String TYPE_BAR_GLASS = "bar_glass";
	
	/**
	 * 3D柱状图
	 */
	public static final String TYPE_BAR_3D = "bar_3d";
	
	/**
	 * 圆柱柱状图
	 */
	public static final String TYPE_BAR_CYLINDER="bar_cylinder";
	
	/**
	 * 线段图
	 */
	public static final String TYPE_LINE = "line";
	
	/**
	 * 饼图
	 */
	public static final String TYPE_PIE = "pie";

	/**
	 * 图表类型
	 */
	private String type;

	/**
	 * 图表的透明度 0(透明)和1(不透明)之间的值
	 */
	private double alpha;

	/**
	 * 图像的颜色
	 * 
	 */
	private String colour;

	/**
	 * 数据名称
	 */
	private String text;

	/**
	 * 字体大小
	 */
	private int fontSize;
	
	/**
	 * 宽度
	 */
	private int width;
	
	/**
	 * 动画效果
	 */
	private ChartElementsOnShow onShow;
	
	/**
	 * 点的样式
	 */
	private ChartElementsDotStyle dotStyle;
	
	/**
	 * 数据的值
	 */
	private Number[] values;

	public ChartElements() {

	}

	public ChartElements(String type, double alpha, String colour, String text,
			int fontSize, Number[] values) {
		this.type = type;
		this.alpha = alpha;
		this.colour = colour;
		this.text = text;
		this.fontSize = fontSize;
		this.values = values;
	}
	
	/**
	 * 将元素的所有属性以字符串形式返回
	 * @return
	 */
	public String getElementString() {
		StringBuffer sb = new StringBuffer();
		sb.append(ChartTool.addHT("{\n"));

		sb.append("\t");
		sb.append(ChartTool.addQuotes("type") + ":");
		sb.append(ChartTool.addQuotes(type) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("alpha") + ":");
		sb.append(ChartTool.checkField("" + alpha) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("colour") + ":");
		sb.append(ChartTool.addQuotes(colour) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("text") + ":");
		sb.append(ChartTool.addQuotes(text) + ",\n");
		
		sb.append("\t");
		sb.append(ChartTool.addQuotes("width") + ":");
		sb.append(ChartTool.checkField(""+width) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("font-size") + ":");
		sb.append(ChartTool.checkField(""+fontSize) + ",\n");
		
		sb.append(dotStyle.getDotStyleString());
		sb.append(onShow.getOnShowString());
		
		sb.append("\t");
		sb.append(ChartTool.addQuotes("values") + ":[");
		if (values != null) {
			for (int i = 0; i < values.length; i++) {
				if (i != values.length - 1) {
					sb.append(""+values[i]+",");
				} else {
					sb.append(""+values[i]);
				}
			}
		}
		sb.append("]\n");
		sb.append(ChartTool.addHT("}"));
		return sb.toString();
	}
	
	/**
	 * 默认设定
	 */
	public void DefaultSetting(){
		type = new String(TYPE_BAR);
		colour = new String();
		text = new String();
		width = 1;
		alpha = 0.5;
		fontSize = 16;
		onShow = new ChartElementsOnShow();
		onShow.DefaultSetting();
		dotStyle = new ChartElementsDotStyle();
		dotStyle.DefaultSetting();
	}
	

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public double getAlpha() {
		return alpha;
	}

	public void setAlpha(double alpha) {
		this.alpha = alpha;
	}

	public String getColour() {
		return colour;
	}

	public void setColour(String colour) {
		this.colour = colour;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public int getFontSize() {
		return fontSize;
	}

	public void setFontSize(int fontSize) {
		this.fontSize = fontSize;
	}

	public ChartElementsOnShow getOnShow() {
		return onShow;
	}

	public void setOnShow(ChartElementsOnShow onShow) {
		this.onShow = onShow;
	}

	public Number[] getValues() {
		return values;
	}

	public void setValues(Number[] values) {
		this.values = values;
	}

	public ChartElementsDotStyle getDotStyle() {
		return dotStyle;
	}

	public void setDotStyle(ChartElementsDotStyle dotStyle) {
		this.dotStyle = dotStyle;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}


}
